VERSION 5.00
Begin VB.Form ScriptLoader 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Add A Script to this X-Bot"
   ClientHeight    =   2985
   ClientLeft      =   45
   ClientTop       =   315
   ClientWidth     =   4845
   Icon            =   "ScriptLoader.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2985
   ScaleWidth      =   4845
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton butViewScript 
      Caption         =   "&View Script's Contents"
      Height          =   525
      Left            =   3120
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2040
      Width           =   1575
   End
   Begin VB.CommandButton butImport 
      Caption         =   "&Import Script"
      Height          =   290
      Left            =   3120
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   2640
      Width           =   1575
   End
   Begin VB.CommandButton butCancel 
      Caption         =   "&Cancel"
      Height          =   290
      Left            =   3120
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   480
      Width           =   1575
   End
   Begin VB.CommandButton butAddScript 
      Caption         =   "&Add Selected Script"
      Height          =   290
      Left            =   3120
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   120
      Width           =   1575
   End
   Begin VB.FileListBox ScriptFile 
      Height          =   3015
      Left            =   0
      Pattern         =   "*.tcl"
      TabIndex        =   0
      Top             =   0
      Width           =   3015
   End
   Begin VB.Image Bkg 
      Height          =   3255
      Left            =   0
      Stretch         =   -1  'True
      Top             =   0
      Width           =   6705
   End
End
Attribute VB_Name = "ScriptLoader"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub butAddScript_Click()
Window.lstScripts.AddItem ScriptFile
Window.butRemScript.Enabled = True

Unload Me
End Sub

Private Sub butCancel_Click()
Unload Me
End Sub

Private Sub butImport_Click()
On Error Resume Next

Dim ImportFile As String
Dim ActualFileName As String
Dim Counter As Integer

ImportFile = OT_GetFile(Me, App.Path & "\windrop\scripts", ".TCL", "Eggdrop TCL Script (*.tcl)" & Chr(0) & "*.tcl" & Chr(0) & Chr(0), 0, "Import Script")
ImportFile = Trim(ImportFile)
ImportFile = Parse(ImportFile, Chr(0), "")

ActualFileName = ""

'MsgBox "ImportFile: " & ImportFile & Chr(13) & Chr(10) & "ActualFileName: " & ActualFileName & Chr(13) & Chr(10) & "Counter:" & Counter

Counter = 1
Do Until InStr(ActualFileName, "\")
    ActualFileName = Right(ImportFile, Counter)
    'MsgBox "ImportFile: " & ImportFile & "-" & "Counter:" & Counter & "-" & "ActualFileName: " & ActualFileName
    
    'MsgBox ActualFileName
    
    ImportFile = Trim(ImportFile)
    ImportFile = Parse(ImportFile, Chr(0), "")
    
    Counter = Counter + 1
Loop

On Error Resume Next
FileCopy ImportFile, App.Path & "\windrop\scripts" & ActualFileName

ScriptFile.Path = App.Path
ScriptFile.Path = App.Path & "\windrop\scripts"
End Sub

Private Sub butViewScript_Click()
butViewScript.Enabled = False
Shell "write.exe " & Chr(34) & App.Path & "\windrop\scripts\" & ScriptFile & Chr(34), vbNormalFocus

DoEvents
butViewScript.Enabled = True

End Sub

Private Sub Form_Load()
On Error Resume Next

'Load Images
Me.Icon = xsplash.Icon

Bkg.Picture = Window.ConstructionImage.Picture

butAddScript.Picture = xsplash.button.Picture
butCancel.Picture = xsplash.button.Picture
butImport.Picture = xsplash.button.Picture
butViewScript.Picture = xsplash.button.Picture

ScriptFile.Path = App.Path & "\windrop\scripts"
ScriptFile.ListIndex = 0
Me.Visible = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
If Window.lstScripts.ListCount < 1 Then
    Window.butRemScript.Enabled = False
Else
    Window.butRemScript.Enabled = True
End If
End Sub


